/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.feignimpl.distribution;

import com.enation.app.javashop.client.distribution.DistributionClient;
import com.enation.app.javashop.core.client.fallback.distribution.DistributionClientFallbackFactory;
import com.enation.app.javashop.core.handler.FeignConfiguration;
import com.enation.app.javashop.model.distribution.dos.DistributionDO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * DistributionClient
 *
 * @author Chopper
 * @version v1.0
 * @since v7.0
 * 2018-08-14 下午1:54
 */
@FeignClient(name = "distribution-service", fallbackFactory = DistributionClientFallbackFactory.class,configuration = {FeignConfiguration.class})
public interface DistributionClientFeignImpl extends DistributionClient {

    /**
     * 新增分销商
     *
     * @param distributor
     * @return
     */
    @Override
    @RequestMapping(value = "/client/distribution/add", method = RequestMethod.POST)
    DistributionDO add(@RequestBody DistributionDO distributor);

    /**
     * 更新Distributor信息
     *
     * @param distributor
     * @return
     */
    @Override
    @RequestMapping(value = "/client/distribution/edit", method = RequestMethod.POST)
    DistributionDO edit(@RequestBody DistributionDO distributor);

    /**
     * 获取分销商
     *
     * @param memberId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/distribution/get", method = RequestMethod.GET)
    DistributionDO getDistributorByMemberId(@RequestParam("member_id") Long memberId);

    /**
     * 根据会员id设置其上级分销商（两级）
     *
     * @param memberId 会员id
     * @param parentId 上级会员的id
     * @return 设置结果， trun=成功 false=失败
     */
    @Override
    @RequestMapping(value = "/client/distribution/set", method = RequestMethod.POST)
    boolean setParentDistributorId(@RequestParam("member_id") Long memberId, @RequestParam("parent_id") Long parentId);
}
